﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Threading;
using System.Runtime.Remoting;

namespace FiveStone
{
    public partial class Online : Form
    {
        public Online()
        {
            InitializeComponent();
        }

        private void btJoin_Click(object sender, EventArgs e)
        {
            if (txbIP.Text.Trim() == string.Empty || txbPort.Text.Trim() == string.Empty)
            {
                MessageBox.Show("主机IP和端口不能为空！", "提示");
            }
            else
            {
                //MySocket.TcpSend("hello,world!");
                btJoin.Enabled = false;
                //while (!MySocket.tcpConnect)
                //{
                //    Program.isOnline = true;
                //    this.Close();
                //}
            }
        }

        private void btCancel_Click(object sender, EventArgs e)
        {
            //MySocket.StopTcpListen();
            this.Close();
        }

        private void Online_Load(object sender, EventArgs e)
        {
            lbIP.Text = MySocket.GetServerIP().ToString();
            lbPort.Text = txbPort.Text = "8000";

            MySocket.IP = txbIP.Text = lbIP.Text = "127.0.0.1";
            MySocket.Port = lbPort.Text;

            
        }                
                
        private void btCreate_Click(object sender, EventArgs e)
        {
            //MySocket.RunTcpListen();
            btCreate.Enabled = false;
            lbWait.Visible = true;
            //while (!MySocket.tcpListen)
            //{
            //    Program.isOnline = true;
            //    this.Close();
            //}
            //远程化游戏对象
            RemotingConfiguration.Configure(
                AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);
            //获得游戏对象的IP地址
            Uri uri = new Uri(Boards.BuildRemotingUrl("localhost"));
            //获得游戏的远程对象
        }

        private void button2_Click(object sender, EventArgs e)
        {
            //MySocket.StopSend();
            this.Close();
        }

    }
}
